package com.j.lemon.learn.pulsar;

import org.apache.pulsar.client.api.*;

/**
 * @Author lijunjun
 * @Date 2020/9/14 11:25
 * @Description
 */
public class ConsumerExclusive {

    public static void main(String[] args) throws PulsarClientException {
        PulsarClient pulsarClient = PulsarUtils.getClient();
        Consumer<byte[]> exclusiveConsumer = pulsarClient.newConsumer()
                .subscriptionType(SubscriptionType.Exclusive)
                .consumerName("exclusiveConsumer")
                .subscriptionName("subscriptionType-test")
                .topic("persistent://4a/audit/subscriptionType-test")
                .subscribe();
        while (true){
            Message<byte[]> receive = exclusiveConsumer.receive();
            System.out.println("receive message: " + new String(receive.getData()));
        }
    }
}
